The present invention relates in general to graphics processing devices with texture filtering, and in particular to a filtering unit for floating-point texture data.
Texture blending is a common technique for achieving various effects in computer generated images, such as realistic modeling of rough surfaces (e.g., brick or stone walls), fabric patterns, etc. Texture blending generally involves defining a texture map, most often as an array of “texels.” Each texel has unique coordinates (e.g., in two or three dimensions), a color, and in some instances other attributes such as a surface normal. To apply the texture to the surface of an object (e.g., a wall or an article of clothing), fixed points on the object surface are assigned texture coordinates. After determining that a given fragment (or pixel) of the rendered image contains a particular point on the object surface, the texture coordinates are used to fetch one or more texels from the texture map, and the color and/or other attributes of the fetched texel(s) are used in shading the fragment.
Typical texture maps are defined such that the portion of the object surface contained within a given fragment covers portions of several texels. For example, the same texture is mapped at multiple levels of detail (LODs) so that, regardless of what fraction of the object surface is contained within a fragment, the number of texels to which the fragment maps can be controlled by selecting a texture map with an appropriate LOD.
Where multiple texels are covered by a fragment, the respective attributes of these texels are combined (filtered) to determine the texture attributes applicable to the fragment. For instance, FIG. 1 illustrates a conventional texture map 100 in a 2D space defined by texture coordinates (s, t). Texture map 100 includes texels 101, 102, 103, 104, which have respective values a, b, c, d for some attribute (e.g., color). A fragment 110 (dashed box) is mapped onto texture map 100 (e.g., by assigning texture coordinates to each corner of pixel 110) in such a way that it covers a portion of each of texels 101, 102, 103, 104. The texture attribute F for pixel 110 can be computed using the well known bilinear filtering formula:F(a,b,c,d)=wt*[ws*a+(1−ws)*b]+(1−wt)*[ws*c+(1−ws)*d],   (Eq. 1)where ws and wt are weight parameters (in the range [0, 1]) that can be determined from distances in the st plane as shown in FIG. 1.
Other types of texture filters are also in common use. For instance, trilinear filtering is frequently used in conjunction with texture maps that represent the same texture at different levels of detail (LODs). The two nearest LODs for a given fragment are selected (usually based on distance from the eyepoint to the object surface being rendered), and a bilinear filter is applied at each of these two LODs to obtain two filtered values F1 and F2 in accordance with Eq. 1. The final result F is a weighted average of F1 and F2, where respective weights p and 1−p are assigned to the two LODs (e.g., based on the distance from the eyepoint to the object surface). Anisotropic texture filters are also known, in which different numbers of texels are considered in different directions in a 2D or 3D texture space. Like trilinear filters, anisotropic filters can often be implemented as weighted averages of results of multiple bilinear filtering operations.
Such filters can be computationally intensive, and graphics processors often include specialized texture filtering units that can quickly compute a filtered texture value from a set of input texture values and weights. A typical texture filtering unit includes a bilinear interpolation (“Bilerp”) circuit and an accumulator circuit. The Bilerp circuit receives four texture values (a, b, c, d) and two weights (ws, wt) and applies a bilinear filter (e.g., Eq. 1). The accumulator circuit computes a weighted sum of the results of different passes through the Bilerp circuit using per-pass weights wf, where different texture values (a, b, c, d) and weights (ws, wt, wf) can be supplied for each pass. Thus, trilinear filtering can be implemented by instructing the accumulator circuit to accumulate results of two passes through the Bilerp circuit (with per-pass weights p and 1−p). Anisotropic filtering can involve accumulating larger numbers (e.g., up to 24) of passes with appropriate per-pass weights.
To reduce chip area and cost, texture filtering circuits are conventionally implemented using fixed-point arithmetic circuits. Fixed-point texture data, however, limits the degree of detail (e.g., subtle color variations) that can be captured in a texture map; in principle, greater realism can be achieved by using floating-point texture data. To support floating-point data, conventional texture filtering units require modification.
Replacing the fixed-point arithmetic circuits of a conventional texture filtering unit (e.g., in the Bilerp and accumulator circuits) with standard floating-point arithmetic circuits significantly increases chip area and cost. In addition, existing graphics application programs generally use fixed-point texture data, so fast filtering of fixed-point texture data also needs to be supported. Supporting fixed-point texture data would require either converting the texture data to floating-point format and converting the filter result back to fixed-point format (which would slow the processing of fixed-point texture data) or providing a separate fixed-point filtering circuit (which would further increase chip area and complexity).
It would therefore be desirable to provide an efficient texture filtering unit that is capable of processing both floating-point and fixed-point texture data.